home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Suzy B Software 2
/
Suzy B Software CD-ROM 2 (1994).iso
/
mintprgs
/
mintupgr
/
disk7.zoo
/
elvis.zoo
/
usr
/
doc
/
elvis
/
ex.doc
< prev
next >
Wrap
Text File
|
1992-08-12
|
20KB
|
661 lines
_3. _C_O_L_O_N _M_O_D_E _C_O_M_M_A_N_D_S
LINES COMMAND ARGUMENTS
ab[br] [short] [expanded form]
[line] a[ppend][!]
ar[gs] [files]
cc [files]
cd[!] [directory]
[line][,line] c[hange]
chd[ir][!][directory]
[line][,line] co[py] line
col[or] [when] [[light] color] [on color]
[line][,line] d[elete] [x]
dig[raph][!][XX [Y]]
e[dit][!] [file]
er[rlist][!][errlist]
f[ile] [file]
[line][,line] g[lobal] /regexp/ command
[line] i[nsert]
[line][,line] j[oin][!]
[line][,line] l[ist]
mak[e] [target]
map[!] key mapped_to
[line] ma[rk] x
mk[exrc]
[line][,line] m[ove] line
n[ext][!] [files]
N[ext][!]
[line][,line] nu[mber]
[line][,line] p[rint]
[line] pu[t] [x]
q[uit][!]
[line] r[ead] file
rew[ind][!]
se[t] [options]
so[urce] file
[line][,line] s[ubstitute]/regexp/replacement/[p][g][c]
ta[g][!] tagname
una[bbr] [short]
u[ndo]
unm[ap][!]key
ve[rsion]
[line][,line] v[global] /regexp/ command
vi[sual] [filename]
wq
[line][,line] w[rite][!][[>>]file]
x[it][!]
[line][,line] y[ank] [x]
[line][,line] ! command
[line][,line] <
[line][,line] =
[line][,line] >
[line][,line] &
@ x
August 10, 1992
3-2 COLON MODE COMMANDS 3-2
To use colon mode commands, you must switch from visual
command mode to colon command mode. The visual mode com-
mands to do this are ":" for a single colon command, or "Q"
for many colon mode commands.
_3._1. _L_i_n_e _S_p_e_c_i_f_i_e_r_s
Line specifiers are always optional. The first line
specifier of most commands usually defaults to the current
line. The second line specifier usually defaults to be the
same as the first line specifier. Exceptions are :write,
:global, and :vglobal, which act on all lines of the file by
default, and :!, which acts on no lines by default.
Line specifiers consist of an absolute part and a rela-
tive part. The absolute part of a line specifier may be
either an explicit line number, a mark, a dot to denote the
current line, a dollar sign to denote the last line of the
file, or a forward or backward search.
An explicit line number is simply a decimal number,
expressed as a string of digits.
A mark is typed in as an apostrophe followed by a
letter. Marks must be set before they can be used. You can
set a mark in visual command mode by typing "m" and a
letter, or you can set it in colon command mode via the
"mark" command.
A forward search is typed in as a regular expression
surrounded by slash characters; searching begins at the
default line. A backward search is typed in as a regular
expression surrounded by question marks; searching begins at
the line before the default line.
If you omit the absolute part, then the default line is
used.
The relative part of a line specifier is typed as a "+"
or "-" character followed by a decimal number. The number
is added to or subtracted from the absolute part of the line
specifier to produce the final line number.
As a special case, the % character may be used to
specify all lines of the file. It is roughly equivelent to
saying 1,$. This can be a handy shortcut.
Some examples:
:p print the current line
:37p print line 37
:'gp print the line which contains mark g
:/foo/p print the next line that contains "foo"
:$p print the last line of the file
August 10, 1992
3-3 COLON MODE COMMANDS 3-3
:20,30p print lines 20 through 30
:1,$p print all lines of the file
:%p print all lines of the file
:/foo/-2,+4p print 5 lines around the next "foo"
_3._2. _T_e_x_t _E_n_t_r_y _C_o_m_m_a_n_d_s
[line] append
[line][,line] change ["x]
[line] insert
The append command inserts text after the specified
line.
The insert command inserts text before the specified
line.
The change command copies the range of lines into a cut
buffer, deletes them, and inserts new text where the old
text used to be.
For all of these commands, you indicate the end of the
text you're inserting by hitting ^D or by entering a line
which contains only a period.
_3._3. _C_u_t & _P_a_s_t_e _C_o_m_m_a_n_d_s
[line][,line] delete ["x]
[line][,line] yank ["x]
[line] put ["x]
[line][,line] copy line
[line][,line] to line
[line][,line] move line
The delete command copies the specified range of lines
into a cut buffer, and then deletes them.
The yank command copies the specified range of lines
into a cut buffer, but does *not* delete them.
The put command inserts text from a cut buffer after
the specified line.
The copy and to commands yank the specified range of
lines and then immediately paste them after some other line.
The move command deletes the specified range of lines
and then immediately pastes them after some other line. If
the destination line comes after the deleted text, then it
will be adjusted automatically to account for the deleted
lines.
August 10, 1992
3-4 COLON MODE COMMANDS 3-4
_3._4. _D_i_s_p_l_a_y _T_e_x_t _C_o_m_m_a_n_d_s
[line][,line] print
[line][,line] list
[line][,line] number
The print command displays the specified range of
lines.
The number command displays the lines, with line
numbers.
The list command also displays them, but it is careful
to make control characters visible.
_3._5. _G_l_o_b_a_l _O_p_e_r_a_t_i_o_n_s _C_o_m_m_a_n_d_s
[line][,line] global /regexp/ command
[line][,line] vglobal /regexp/ command
The global command searches through the lines of the
specified range (or through the whole file if no range is
specified) for lines that contain a given regular expres-
sion. It then moves the cursor to each of these lines and
runs some other command on them.
The vglobal command is similar, but it searches for
lines that _d_o_n'_t contain the regular expression.
_3._6. _L_i_n_e _E_d_i_t_i_n_g _C_o_m_m_a_n_d_s
[line][,line] join[!]
[line][,line] ! program
[line][,line] <
[line][,line] >
[line][,line] substitute /regexp/replacement/[p][g][c]
[line][,line] &
The join command catenates all lines in the specified
range together to form one big line. If only a single line
is specified, then the following line is catenated onto it.
The normal ":join" inserts one or two spaces between the
lines; the ":join!" variation (with a '!') doesn't insert
spaces.
The ! command runs an external filter program, and
feeds the specified range of lines to it's stdin. The lines
are then replaced by the output of the filter. A typical
example would be ":'a,'z!sort" to sort the lines 'a,'z.
The < and > commands shift the specified range of lines
August 10, 1992
3-5 COLON MODE COMMANDS 3-5
left or right, normally by the width of 1 tab character.
The "shiftwidth" option determines the shifting amount.
The substitute command finds the regular expression in
each line, and replaces it with the replacement text. The
"p" option causes the altered lines to be printed. The "g"
option permits all instances of the regular expression to be
found & replaced. (Without "g", only the first occurrence
in each line is replaced.) The "c" option asks for confirma-
tion before each substitution.
The & command repeats the previous substitution com-
mand. Actually, "&" is equivelent to "s//~/" with the same
options as last time. It searches for the last regular
expression that you specified for any purpose, and replaces
it with the the same text that was used in the previous sub-
stitution.
_3._7. _U_n_d_o _C_o_m_m_a_n_d
undo
The undo command restores the file to the state it was
in before your most recent command which changed text.
_3._8. _C_o_n_f_i_g_u_r_a_t_i_o_n & _S_t_a_t_u_s _C_o_m_m_a_n_d_s
map[!] [key mapped_to]
unmap[!] key
abbr [word expanded_form_of_word]
unabbr word
digraph[!] [XX [Y]]
set [options]
mkexrc
[line] mark "x
visual
version
[line][,line] =
file [file]
source file
@ "x
color [when] [["light"] color] ["on" color]
The map command allows you to configure Elvis to recog-
nize your function keys, and treat them as though they
transmitted some other sequence of characters. Normally
this mapping is done only when in the visual command mode,
but with the [!] present it will map keys under input and
replace modes as well. When this command is given with no
arguments, it prints a table showing all mappings currently
in effect. When called with two arguments, the first is the
sequence that your function key really sends, and the second
August 10, 1992
3-6 COLON MODE COMMANDS 3-6
is the sequence that you want Elvis to treat it as having
sent. As a special case, if the first argument is a number
then Elvis will map the corresponding function key; for
example, ":map 7 dd" will cause the <F7> key to delete a
line.
The unmap command removes key definitions that were
made via the map command.
The abbr command is used to define/list a table of
abbreviations. The table contains both the abbreviated form
and the fully spelled-out form. When you're in visual input
mode, and you type in the abbreviated form, Elvis will
replace the abbreviated form with the fully spelled-out
form. When this command is called without arguments, it
lists the table; with two or more arguments, the first argu-
ment is taken as the abbreviated form, and the rest of the
command line is the fully-spelled out form.
The unabbr command deletes entries from the abbr table.
The digraph command allows you to display the set of
digraphs that Elvis is using, or add/remove a digraph. To
list the set of digraphs, use the digraph command with no
arguments. To add a digraph, you should give the digraph
command two arguments. The first argument is the two ASCII
characters that are to be combined; the second is the non-
ASCII character that they represent. The non-ASCII
character's most significant bit is automatically set by the
digraph command, unless to append a ! to the command name.
Removal of a digraph is similar to adding a digraph, except
that you should leave off the second argument.
The set command allows you examine or set various
options. With no arguments, it displays the values of
options that have been changed. With the single argument
"all" it displays the values of all options, regardless of
whether they've been explicitly set or not. Otherwise, the
arguments are treated as options to be set.
The mkexrc command saves the current configuration to a
file called ".exrc" in the current directory.
The mark command defines a named mark to refer to a
specific place in the file. This mark may be used later to
specify lines for other commands.
The visual command puts the editor into visual mode.
Instead of emulating ex, Elvis will start emulating vi.
The version command tells you that what version of
Elvis this is.
The = command tells you what line you specified, or, if
August 10, 1992
3-7 COLON MODE COMMANDS 3-7
you specified a range of lines, it will tell you both end-
points and the number of lines included in the range.
The file command tells you the name of the file,
whether it has been modified, the number of lines in the
file, and the current line number. You can also use it to
change the name of the current file.
The source command reads a sequence of colon mode com-
mands from a file, and interprets them.
The @ command executes the contents of a cut-buffer as
EX commands.
The color command only works under MS-DOS, or if you
have an ANSI-compatible color terminal. It allows you to
set the foreground and background colors for different types
of text: normal, bold, italic, underlined, standout, pop-up
menu, and visible selection. By default, it changes the
"normal" colors; to change other colors, the first argument
to the :color command should be the first letter of the type
of text you want. The syntax for the colors themselves is
fairly intuitive. For example, ":color light cyan on blue"
causes normal text to be displayed in light cyan on a blue
background, and ":color b bright white" causes bold text to
be displayed in bright white on a blue background. The
background color always defaults to the current background
color of normal text. Your first :color command _m_u_s_t
specify both the foreground and background for normal text.
_3._9. _M_u_l_t_i_p_l_e _F_i_l_e _C_o_m_m_a_n_d_s
args [files]
next[!] [files]
Next[!]
previous[!]
rewind[!]
When you invoke Elvis from your shell's command line,
any filenames that you give to Elvis as arguments are stored
in the args list. The args command will display this list,
or define a new one.
The next command switches from the current file to the
next one in the args list. You may specify a new args list
here, too.
The Next and previous commands (they're really aliases
for the same command) switch from the current file to the
preceding file in the args list.
The rewind command switches from the current file to
the first file in the args list.
August 10, 1992
3-8 COLON MODE COMMANDS 3-8
_3._1_0. _S_w_i_t_c_h_i_n_g _F_i_l_e_s
edit[!] [file]
tag[!] tagname
The edit command allows to switch from the current file
to some other file. This has nothing to do with the args
list, by the way.
The tag command looks up a given tagname in a file
called "tags". This tells it which file the tag is in, and
how to find it in that file. Elvis then switches to the
tag's file and finds the tag.
_3._1_1. _W_o_r_k_i_n_g _w_i_t_h _a _C_o_m_p_i_l_e_r
cc [files]
make [target]
errlist[!] [errlist]
The cc and make commands execute your compiler or
"make" utility and redirect any error messages into a file
called "errlist". By default, cc is run on the current
file. (You should write it before running cc.) The contents
of the "errlist" file are then scanned for error messages.
If an error message is found, then the cursor is moved to
the line where the error was detected, and the description
of the error is displayed on the status line.
After you've fixed one error, the errlist command will
move the cursor to the next error. In visual command mode,
hitting `*' will do this, too.
You can also create an "errlist" file from outside of
Elvis, and use "Elvis -m" to start elvis and have the cursor
moved to the first error. Note that you don't need to sup-
ply a filename with "Elvis -m" because the error messages
always say which source file an error is in.
Note: When you use errlist repeatedly to fix several
errors in a single file, it will attempt to adjust the
reported line numbers to allow for lines that you have
inserted or deleted. These adjustments are made with the
assumption that you will work though the file from the
beginning to the end.
_3._1_2. _E_x_i_t _C_o_m_m_a_n_d_s
quit[!]
wq
xit
August 10, 1992
3-9 COLON MODE COMMANDS 3-9
The quit command exits from the editor without saving
your file.
The wq command writes your file out, then then exits.
The xit command is similar to the wq command, except
that xit won't bother to write your file if you haven't
modified it.
_3._1_3. _F_i_l_e _I/_O _C_o_m_m_a_n_d_s
[line] read file
[line][,line] write[!] [[>>]file]
The read command gets text from another file and
inserts it after the specified line. It can also read the
output of a program; simply precede the program name by a
'!' and use it in place of the file name.
The write command writes the whole file, or just part
of it, to some other file. The !, if present, will permit
the lines to be written even if you've set the readonly
option. If you precede the filename by >> then the lines
will be appended to the file. You can send the lines to the
standard input of a program by replacing the filename with a
'!' followed by the command and its arguments.
Note: Be careful not to confuse ":w!filename" and ":w
!command". To write to a program, you must have at least
one blank before the '!'.
_3._1_4. _D_i_r_e_c_t_o_r_y _C_o_m_m_a_n_d_s
cd [directory]
chdir [directory]
shell
The cd and chdir commands (really two names for one
command) switch the current working directory.
The shell command starts an interactive shell.
_3._1_5. _D_e_b_u_g_g_i_n_g _C_o_m_m_a_n_d_s
[line][,line] debug[!]
validate[!]
These commands are only available if you compile Elvis
with the -DDEBUG flag.
The debug command lists statistics for the blocks which
August 10, 1992
3-10 COLON MODE COMMANDS 3-10
contain the specified range of lines. If the ! is present,
then the contents of those blocks is displayed, too.
The validate command checks certain variables for
internal consistency. Normally it doesn't output anything
unless it detects a problem. With the !, though, it will
always produce *some* output.
August 10, 1992